package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndCity;
import com.bestow.basic.service.IFndCityService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 市Controller
 * 
 * @author liliu
 * @date 2022-09-06
 */
@RestController
@RequestMapping("/basic/fndCity")
public class FndCityController extends BaseController
{
    @Autowired
    private IFndCityService fndCityService;

    /**
     * 查询市列表
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCity:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndCity fndCity)
    {
        startPage();
        List<FndCity> list = fndCityService.selectFndCityList(fndCity);
        return getDataTable(list);
    }

    /**
     * 导出市列表
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCity:export')")
    @Log(title = "市", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndCity fndCity)
    {
        List<FndCity> list = fndCityService.selectFndCityList(fndCity);
        ExcelUtil<FndCity> util = new ExcelUtil<FndCity>(FndCity.class);
        util.exportExcel(response, list, "市数据");
    }

    /**
     * 获取市详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCity:query')")
    @GetMapping(value = "/{city}")
    public AjaxResult getInfo(@PathVariable("city") String city)
    {
        return AjaxResult.success(fndCityService.selectFndCityByCity(city));
    }

    /**
     * 新增市
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCity:add')")
    @Log(title = "市", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndCity fndCity)
    {
        return toAjax(fndCityService.insertFndCity(fndCity));
    }

    /**
     * 修改市
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCity:edit')")
    @Log(title = "市", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndCity fndCity)
    {
        return toAjax(fndCityService.updateFndCity(fndCity));
    }

    /**
     * 删除市
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCity:remove')")
    @Log(title = "市", businessType = BusinessType.DELETE)
	@DeleteMapping("/{citys}")
    public AjaxResult remove(@PathVariable String[] citys)
    {
        return toAjax(fndCityService.deleteFndCityByCitys(citys));
    }
}
